import request from '@/utils/request'

// 查询单据主列表
export function listHead(query) {
  return request({
    url: '/depotHead/list',
    method: 'get',
    params: query
  })
}
// 获取单据编号
export function buildNumber(type, subType) {
  return request({
    url: '/sequence/buildNumber?type=' + type + '&&subType=' + subType,
    method: 'get'
  })
}

// 查看详情
export function findDepot(headId, isReadOnly) {
  return request({
    url: '/depotItem/getDetailList?headerId=' + headId + '&&isReadOnly=' + isReadOnly,
    method: 'get'
  })
}
export function listSupplier(type) {
  return request({
    url: '/supplier/supplierList/'+type,
    method: 'get'
  })
}

export function listUser() {
  return request({
    url: '/user/list',
    method: 'get'
  })
}

export function getDepotNameList() {
  return request({
    url: '/depot/findDepotByCurrentUser',
    method: 'get'
  })
}

export function getDepotMaterialList(query) {
  return request({
    url: '/material/findBySelect',
    method: 'get',
    params: query
  })
}
export function getMaterialListByCode(mBarCode,depotId) {
  return request({
    url: '/material/getMaterialByBarCode?mBarCode='+mBarCode+'&&depotId='+depotId,
    method: 'get',
  })
}
export function getTenantList() {
  return request({
    url: '/tenant/list',
    method: 'get',
  })
}

export function getcategoryList() {
  return request({
    url: '/materialCategory/getMaterialCategoryTree',
    method: 'get',
  })
}
// 查询单据主详细
export function getHead(id) {
  return request({
    url: '/head/' + id,
    method: 'get'
  })
}

// 修改单据状态
export function upStatus(ids, status) {
  return request({
    url: '/depotHead/batchSetStatus',
    method: 'put',
    params:{'ids':JSON.stringify(ids),'status':status}
  })
}
// 批量删除单据
export function deleteBatch(ids) {
  return request({
    url: '/depotHead/deleteBatch',
    method: 'delete',
    params:{'ids':JSON.stringify(ids)}
  })
}
// 修改单据
export function getDepotHeadAndDetail(info) {
  return request({
    url: '/depotHead/getList?headerId='+info,
    method: 'get',
  })
}

// 新增单据
export function addDepotHeadAndDetail(info) {
  return request({
    url: '/depotHead/addDepotHeadAndDetail',
    method: 'post',
    data:info
  })
}
// 修改单据
export function updateDepotHeadAndDetail(info) {
  return request({
    url: '/depotHead/updateDepotHeadAndDetail',
    method: 'put',
    data:info
  })
}